Visualize mach-o dependencies
In the spirit of Vizualize dependencies in MacPorts and Vizualize KEXTs dependencies, this page describes a way to track mach-o file dependencies and related satellite information (e.g: blockers).
Prerequisites
Graphviz is an opensource graph visualization software from AT&T Laboratories and Bell Laboratories (Lucent Technologies).
port install graphviz +the_variants_you_need
or grab and compile the source from graphviz.org. Note: On Mac OS X, Pixelglow is a nice a front-end, you can even see the graph being built in real-time.
Using pd_machviz to generate a graph
The pd_machviz tool is available in the svn/hg trunk.
A simple example across otool dependencies
A hierarchical view:
The corresponding script output:
./pd_machviz /usr/bin/otool
Generate dependencies graphs of /usr/bin/otool
Legend:
1 + foo
2 |`- bar No more dependency
2 |`+ baz impure! /Blocker_1 -> file_involved_1 Impurity detected
2 |`+ baz impure! /Blocker_. -> file_involved_. Impurity detected
2 |`+ baz impure! /Blocker_n -> file_involved_n Impurity detected
2 |`+ baz Dependency found
3 | |`. qux Cached file (Already processed)
Now generating dependencies tree, please wait…
1 + /usr/bin/otool
2 |`+ /usr/lib/libgcc_s.1.dylib
3 | |`+ /usr/lib/libSystem.B.dylib
4 | | |`- /usr/lib/system/libmathCommon.A.dylib
2 |`. /usr/lib/libSystem.B.dylib
Generation of otool.dot complete.
Now drawing graphs from otool.dot, please wait…
Generation of otool.dot_directed.png complete.
Generation of otool.dot_circular.png complete.
Generation of otool.dot_radial.png complete.
Generation of otool.dot_undirected.png complete.
Generation of otool.dot_undirectedBIS.png complete.
A circular view of xterm dependencies
Checking for purity in passwd
Resources
http://www.graphviz.org the otool page